When data are accessed, accessing is usually performed on the basis of data blocks with a certain length, i.e., when the data are written into a memory, the data are divided into a plurality of data blocks with the same data length, and each of the data blocks is stored, as a whole, in the memory; and, when the data are read from the memory, each of the data blocks is read as a whole. The length of such a data block which is accessed as a whole can be referred to as “data length”.
In the course of writing, storing and reading a data block, error of data bit(s) may occur, and thus there is a need to check and correct the stored data block.
ECC (Error Correction Code) is often used to detect and correct data bit(s) in error in a data block. For example, when data are written into a memory, each data block is considered as a whole with a number of parity bits generated for it, and the resulting data (including data bits of the data block and the number of parity bits) are stored in the memory, wherein generating of each of the parity bits is defined by an ECC encoding rule used. A proper ECC encoding rule and the number of the parity bits can be selected based on the data length of the data block and the number of bit(s) requiring detection and correction.
ECC usually takes the form of linear codes, and for a compromise between error rate and repairing cost, the most common ECC is SEC/DED (single error correcting/double error detecting) codes among linear codes. In the case of SEC/DED codes being used, with a 64-bit data block (whose data length is 64 bits) taken for example, SEC/DED codes in (72, 64) format can be adopted, where 64 denotes the length of data bits, and 72 denotes the sum of the length of data bits and the length of parity bits, i.e., the number of the parity bits is 8.
An ECC memory is a memory that is widely used and has auto-correcting function, and is suitable to store a data block along with parity bits generated for it as described above. Storage arrays of an ECC memory are usually arranged based on the data length of data blocks that the ECC memory is intended to store and ECC (or an ECC encoding rule) that the ECC memory is intended to use. Once being formed, storage arrays of an ECC memory cannot be physically modified. Therefore, usually a single ECC memory is only used to store data blocks with a specific data length.
For instance, FIG. 1 schematically shows a storage array of an ECC memory for data blocks with a data length of 64 bits. In FIG. 1, SEC/DED codes in (72, 64) format are used, with 64 data bits of a data block denoted by d<63:0> and 8 parity bits generated for the data block denoted by p<7:0>. The storage array can be divided into two parts, a data bit storage part A for storing data bits d<63:0>, and a parity bit storage part B for storing parity bits p<7:0>. If the storage array is divided on the basis of storage cells, it can be divided into 9 storage cells, of which 8 storage cells A7˜A0 are included by the data bit storage part A, and one storage cell is included by the parity bit storage part B, and each of the storage cells includes 8 storage bits, in which 8 bits can be stored.
When the system where the ECC memory is located operates in different modes, there may be a need to use data blocks with a different data length, for example, 32-bit data blocks. Then, for 32-bit data blocks, the ECC memory which adopts SEC/DED codes in (72, 64) format as mentioned above and is intended to store data blocks with a data length of 64 bits cannot be used in an efficient manner.